import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

import getters from './getters'
import mutations from './mutations'
import actions from './actions'


Vue.use(Vuex)


const state = {
  geohash: '',
  shopDetailStatus: 0, //在shopSafe页面展示笑脸和哭脸
  shopInfo: {},  //店铺信息
  shopCommodityList: {},  //商品列表
  goods: {},  //购物车展示信息
  userInfo: {},  //用户登录信息
  addresses: {},  //收货地址,
  searchHistory: [] //搜索历史
}



const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  module: {},
  plugins: [createPersistedState({
    // reducer(val) {
    //   return {
    //     // 只储存state中的assessmentData
    //     geohash: val.geohash,
    //     shopDetailStatus: val.shopDetailStatus,
    //     shopInfo: val.shopInfo,
    //     buyCart: val.goods,
    //     userInfo: val.userInfo,
    //     addresses: val.addresses,
    //     searchHistory: val.searchHistory,
    //   }
    // }

  }
  )]
})


export default store